package ace.tool.generate.code.impl.resolver.scheme.resolver.sdk;

import ace.tool.generate.code.impl.manager.common.EntityModelManager;
import ace.tool.generate.code.impl.resolver.scheme.model.bo.sdk.FeignApiClassInfo;
import ace.tool.generate.code.impl.resolver.scheme.model.dto.ClassFileInfo;
import ace.tool.generate.code.impl.resolver.scheme.model.dto.CommonInfo;
import ace.tool.generate.code.impl.resolver.scheme.model.dto.ProjectInfo;
import ace.tool.generate.code.impl.resolver.scheme.resolver.ClassFileInfoResolver;
import ace.tool.generate.code.impl.service.model.input.GenerateInput;
import ace.tool.generate.code.impl.service.model.input.GenerateModelInput;
import lombok.Builder;
import lombok.RequiredArgsConstructor;

/**
 * @author caspar
 * @date 2023/11/17 10:34
 */
@Builder
@RequiredArgsConstructor
public class FeignApiClassInfoResolver {
  private final GenerateInput input;
  private final GenerateModelInput modelInput;
  private final CommonInfo commonInfo;
  private final ProjectInfo sdkProjectInfo;

  public FeignApiClassInfo resolve() {
    String entityModelId = new EntityModelManager().getEntityModelId(input, modelInput);

    ClassFileInfo classFileInfo =
        ClassFileInfoResolver.builder()
            .className(this.modelInput.getName())
            .classNameSuffix(input.getFeignApiClassNameSuffix())
            .classPackagePrefix(input.getFeignApiClassPackagePrefix())
            .rootPackageFullName(commonInfo.getRootPackageFullName())
            .sourceCodeRootDir(sdkProjectInfo.getSourceCodeRootDir())
            .build()
            .resolve();

    return FeignApiClassInfo.builder().info(classFileInfo).entityModelId(entityModelId).build();
  }
}
